package org.csmzxy.class2333;

import java.util.Scanner;

public class Example01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数:");
        int number = scanner.nextInt();
        if (isNarcissistic(number)) {
            System.out.println(number + "是水仙花数");
        }else {
            System.out.println(number + "不是水仙花数");
        }
        scanner.close();
    }

    public static boolean isNarcissistic(int num) {
        int originalNumber = num;
        int numDigits = String.valueOf(num).length();
        int sum = 0;

        while (num != 0) {
            int digit = num % 10;
            sum += Math.pow(digit,numDigits);
            num /= 10;
        }


        return sum == originalNumber;
    }
}
